import store from '~/store'
function hasPermission(value,el=false){ //首先节点不移除
    if(!Array.isArray(value)){
        throw new Error(`需要配置权限例如 v-permission=['getStatistics3,GET']`)
    }
    //true有，false没有
    const hasAuth = value.findIndex(v=>store.state.ruleNames.includes(v))!=-1
    if(el && !hasAuth){
        //删除节点
        el.parentNode && el.parentNode.removeChild(el)
    }
    return hasAuth
}
export default {
    install(app){
        app.directive('permission',{
            //el节点
            mounted(el,binding) {
                // console.log(el,binding);
                // 数组的值
                // binding.value 
                hasPermission(binding.value,el)
            },
        })
    }
}